From: Giovanni Campagna Date: Tue, 25 Jan 2011 21:06:40 +0000 (+0100) Subject: PopupMenu: make parameters overridable in items X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~8921 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=6e236546eafa7eabc1b9db36c2b61acba4f8b773;p=gnome-shell.git PopupMenu: make parameters overridable in items Make all subclasses of PopupMenuBase accept a params argument, which can be used to make the item non reactive, not responsive to hover and, as a new feature, with a different style class. https://bugzilla.gnome.org/show_bug.cgi?id=621707 --- diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 05a67bd87..e3aeffe10 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -26,7 +26,9 @@ PopupBaseMenuItem.prototype = { _init: function (params) { params = Params.parse (params, { reactive: true, activate: true, - hover: true }); + hover: true, + style_class: null + }); this.actor = new Shell.GenericContainer({ style_class: 'popup-menu-item', reactive: params.reactive, track_hover: params.reactive, @@ -43,6 +45,9 @@ PopupBaseMenuItem.prototype = { this._spacing = 0; this.active = false; + if (params.style_class) + this.actor.add_style_class_name(params.style_class); + if (params.reactive && params.activate) { this.actor.connect('button-release-event', Lang.bind(this, this._onButtonReleaseEvent)); this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent)); @@ -527,8 +532,8 @@ function PopupSwitchMenuItem() { PopupSwitchMenuItem.prototype = { __proto__: PopupBaseMenuItem.prototype, - _init: function(text, active) { - PopupBaseMenuItem.prototype._init.call(this); + _init: function(text, active, params) { + PopupBaseMenuItem.prototype._init.call(this, params); this.label = new St.Label({ text: text }); this._switch = new Switch(active); @@ -555,15 +560,15 @@ PopupSwitchMenuItem.prototype = { } }; -function PopupImageMenuItem(text, iconName) { - this._init(text, iconName); +function PopupImageMenuItem() { + this._init.apply(this, arguments); } PopupImageMenuItem.prototype = { __proto__: PopupBaseMenuItem.prototype, - _init: function (text, iconName) { - PopupBaseMenuItem.prototype._init.call(this); + _init: function (text, iconName, params) { + PopupBaseMenuItem.prototype._init.call(this, params); this.label = new St.Label({ text: text }); this.addActor(this.label); @@ -608,8 +613,12 @@ PopupMenuBase.prototype = { _init: function(sourceActor, styleClass) { this.sourceActor = sourceActor; - this.box = new St.BoxLayout({ style_class: styleClass, - vertical: true }); + if (styleClass !== undefined) { + this.box = new St.BoxLayout({ style_class: styleClass, + vertical: true }); + } else { + this.box = new St.BoxLayout({ vertical: true }); + } this.isOpen = false; this._activeMenuItem = null; diff --git a/js/ui/statusMenu.js b/js/ui/statusMenu.js index ecc12b044..dc17f0f7f 100644 --- a/js/ui/statusMenu.js +++ b/js/ui/statusMenu.js @@ -99,12 +99,12 @@ StatusMenuButton.prototype = { _createSubMenu: function() { let item; - item = new PopupMenu.PopupImageMenuItem(_("Available"), 'user-available', true); + item = new PopupMenu.PopupImageMenuItem(_("Available"), 'user-available'); item.connect('activate', Lang.bind(this, this._setPresenceStatus, GnomeSession.PresenceStatus.AVAILABLE)); this.menu.addMenuItem(item); this._presenceItems[GnomeSession.PresenceStatus.AVAILABLE] = item; - item = new PopupMenu.PopupImageMenuItem(_("Busy"), 'user-busy', true); + item = new PopupMenu.PopupImageMenuItem(_("Busy"), 'user-busy'); item.connect('activate', Lang.bind(this, this._setPresenceStatus, GnomeSession.PresenceStatus.BUSY)); this.menu.addMenuItem(item); this._presenceItems[GnomeSession.PresenceStatus.BUSY] = item;